package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.wms.domain.DisassemblePipeline;
import com.ruoyi.wms.service.IDisassemblePipelineService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 拆解流水线Controller
 *
 * @author ruoyi
 * @date 2025-10-16
 */

@Api(value = "拆解流水线Controller", tags = "拆解流水线Controller")
@RestController
@RequestMapping("/pipeline")
public class DisassemblePipelineController extends BaseController {
    @Autowired
    private IDisassemblePipelineService disassemblePipelineService;

    /**
     * 查询拆解流水线列表
     */
    @RequiresPermissions("wms:pipeline:list")
    @GetMapping("/list")
    public TableDataInfo list(DisassemblePipeline disassemblePipeline) {
        startPage();
        List<DisassemblePipeline> list = disassemblePipelineService.selectDisassemblePipelineList(disassemblePipeline);
        return getDataTable(list);
    }




    @ApiOperation("获取拆解流水线详细信息getInfoById")
    @GetMapping(value = "/getInfoByplateNo")
    public AjaxResult getInfoByplateNo(@ApiParam(value = "车牌号码", required = true) @RequestParam(value = "plateNo") String plateNo) {
        return success(disassemblePipelineService.selectDisassemblePipelineById(plateNo));
    }



    /**
     * 修改拆解流水线
     */
    @RequiresPermissions("wms:pipeline:edit")
    @Log(title = "拆解流水线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DisassemblePipeline disassemblePipeline) {
        return toAjax(disassemblePipelineService.updateDisassemblePipeline(disassemblePipeline));
    }

    /**
     * 删除拆解流水线
     */


    @ApiOperation("删除拆解流水线")
    @Log(title = "删除拆解流水线", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(disassemblePipelineService.deleteDisassemblePipelineByIds(ids));
    }



    @ApiOperation("拆解按钮 一次点一个")
    @Log(title = "拆解按钮", businessType = BusinessType.UPDATE)
    @PostMapping("/disassemble")
    public AjaxResult disassemble(@RequestBody String[] ids) {
        if (ids == null || ids.length == 0) {
            return error("未选中");
        }
        return toAjax(disassemblePipelineService.disassemble(ids));
    }


}
